<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	response.setHeader("Pragma", "No-Cache");
	response.setHeader("Cache-Control", "No-Cache");
	response.setDateHeader("Expires", 0);
%>
<!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN" "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
		<title>药典管理-处方冲突检测</title>
		<link type="text/css" rel="stylesheet"
			href="${pageContext.request.contextPath}/drugUI/css/style.css" />
		<link type="text/css" rel="stylesheet"
			href="${pageContext.request.contextPath}/drugUI/css/main.css" />
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/drugUI/js/util.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath}/drugUI/js/jquery1.4.2.min.js"></script>
	</head>
	<body>
		<div id="container">
			<form name="myForm" method="post" id="myForm">
				<!--查询栏 开始-->
				<div class="current">
					<div class="current_con">
						<div class="help">
							<a href="#"><img
									src="${pageContext.request.contextPath}/drugUI/image/help.gif"
									title="帮助"
									onclick="showLayer('C5','${pageContext.request.contextPath}')" />
							</a>
						</div>
						<span>_当前位置：</span> 药典管理 >>处方冲突检测
					</div>
				</div>
				<table class="table02" id="Table1" align="center" width="95%">
				<tr><td style="color:#666666; font-weight:bolder" colspan="6" align="center">患者信息</td></tr>
					<tr>
						<td class="tName" align="center" width="10%">
							年龄
						</td>
						<td width="40%">
							<input type="text" id="age" name="patient.age" style="width: 80%;" />
						</td>
						<td class="tName" align="center" width="10%">
							性别
						</td>
						<td>
							<select name="patient.sex" id="sex" onchange="hiddenIsLady(this.value);">
							<option value="1">男</option>
							<option value="0">女</option>
							</select>
						</td>
					</tr>
					<tr>
						<td class="tName" align="center" width="10%">
							肝功能不全
						</td>
						<td width="40%">
							<input type="radio" name="patient.isLiver" value="true"/>是
							<input type="radio" name="patient.isLiver" value="false" checked="checked"/>否
						</td>
						<td class="tName" align="center" width="10%">
							肾功能不全
						</td>
						<td>
						    <input type="radio" name="patient.isKideny" value="true"/>是
							<input type="radio" name="patient.isKideny" value="false" checked="checked"/>否
						</td>
					</tr>
					<tr id="isLady" style="display:none;">
						<td class="tName" align="center" width="10%">
							妊娠期妇女
						</td>
						<td width="40%">
							<input type="radio" name="patient.isPregnancy" value="true"/>是
							<input type="radio" name="patient.isPregnancy" value="false" checked="checked"/>否
						</td>
						<td class="tName" align="center" width="10%">
							哺乳期妇女
						</td>
						<td>
						    <input type="radio" name="patient.isFeed" value="true"/>是
							<input type="radio" name="patient.isFeed" value="false" checked="checked"/>否
						</td>
					</tr>
					<tr>
						<td class="td_bottom" align="center" colSpan="4">
							<input type="button" name="btnSearch" value="冲突检测"
								onClick="javascript:recipeCheck();" id="btnSearch" class="btn02" />
						</td>
					</tr>
				</table>
				<!--查询栏 结束-->
				<div id="checkresults" style="display:none;">
				<c:forEach items="${results}" var="result" varStatus="i">
				     <c:forEach items="${result}" var="s" varStatus="i">
				     <font color="red">${s}</font><br/>
				     </c:forEach>
				</c:forEach>
				</div>
				<!--列表输出-->
				<div id="content">
					<div id="tabContainer">
						<!--列表输出表头-->
						<!--列表输出表头-->
						<div id="tabTitle">
						<table width="100%" class="table01" align="center" cellspacing="0">
							<tr align="center" class="tr_title">
									<td width="5%" height="30" scope="col">
										<input id='cbSelectAll' name='cbSelectAll' type='checkbox'
											onclick="selectOrCancelBox( 'cbSelectAll', 'ids' );" />
									</td>
									<td width="20%" scope="col">
										药品名称
									</td>
									<td width="15%" scope="col">
										单位
									</td>
									<td width="15%" scope="col">
										剂量
									</td>
									<td width="15%" scope="col">
										频次
									</td>
									<td width="15%" scope="col">
										天数
									</td>
									<td width="15%" scope="col">
										说明
									</td>
								</tr>
							</table>
						</div>
						<!--列表输出各行数据-->
						<div id="tabLines">
							<table class="table01" width="100%"
								style="TABLE-LAYOUT: fixed; word-break: break-all"
								align="center" cellspacing="0">
								<input type="hidden" name="checkList" id="checkList"/>
								<tbody id="__list">
									<c:forEach items="${recipedetails}" var="s" varStatus="i">
										<tr <c:if test="${i.index%2==0}"> class = 'tr_1'</c:if>
											<c:if test="${i.index%2==1}"> class = 'tr_2'</c:if>>
											<td width="5%" scope="col">
												<input name='ids' type='checkbox'
													value="${ s.id }" />
											</td>
											<td width="20%">${s.drug.drugname}
											</td>
											<td width="15%">
												${s.unit}
											</td>
											<td width="15%">
												${s.dosage}
											</td>
											<td width="15%">
												${s.frequency }
											</td>
											<td width="15%">
												${s.days}
											</td>
											<td width="15%">
												${s.tips }
											</td>
										</tr>
									</c:forEach>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</form>
		</div>
		<script language="javascript">
		function hiddenIsLady(sex)
		{
		   if(trim(document.getElementById('age').value)=='')
		   { 
		      alert("请输入患者年龄");
		      document.getElementById('age').select();
		      document.getElementById('sex').selectedIndex=0;
		      return false;
		   }
		   if(!isInteger(document.getElementById('age').value))
		   { 
		      alert("患者年龄只能为整数");
		      document.getElementById('age').select();
		      document.getElementById('sex').selectedIndex=0;
		      return false;
		   }
		   if(!(document.getElementById('age').value>=22&&document.getElementById('age').value<=50)&&(document.getElementById('sex').value=='0'))
		   {
		       alert('22-50年龄段女性为孕妇较为合理,请重新选择');
		       document.getElementById('sex').selectedIndex=0;
		       return false;
		   }
		document.getElementById('checkresults').style.display="none";
		var trID=document.getElementById('isLady');
		if(sex=='0')
		{
		trID.style.display='block';
		}
		else
		{
		trID.style.display='none';
		}
		}
		function recipeCheck(){
		   document.getElementById('checkresults').style.display="none";
		   if(trim(document.getElementById('age').value)=='')
		   { 
		      alert("请输入患者年龄");
		      document.getElementById('age').select();
		      document.getElementById('sex').selectedIndex=0;
		      return false;
		   }
		   if(!isInteger(document.getElementById('age').value))
		   { 
		      alert("患者年龄只能为整数");
		      document.getElementById('age').select();
		      document.getElementById('sex').selectedIndex=0;
		      return false;
		   }
		   
		   if(!(document.getElementById('age').value>=22&&document.getElementById('age').value<=50)
		   &&(document.getElementById('sex').value=='0'))
		   {
		       alert('22-50年龄段女性为孕妇较为合理,请重新选择');
		       document.getElementById('sex').selectedIndex=0;
		       return false;
		   }
		   var cBox = document.getElementsByName( "ids" );
		   var flag=false;
		   var checkCount=0;
		   for(i=0;i<cBox.length;i++)
		   {
		       if(cBox[i].checked)
		         {
		          flag=true;
		          checkCount++;
		         }
		   }
		   if(!flag)
		   {
		       alert( "请选择处方!" );
			   return false;
		   }
		   if(checkCount<2)
		   {
		       alert( "选择处方的条数至少为2!" );
			   return false;
		   }
		   var pprcd = getCheckBoxValues("ids");
		   document.getElementById('checkList').value=pprcd;
		   document.myForm.action = "check.recipeCheck.action";
		   document.myForm.submit();
		}
		function statusInfo() {
	    var status = "${status}";
		if (status == "0")
			alert("处方无冲突！");
		else if (status == "1") {
		    alert("处方有冲突,具体信息见页面红色提示！");
			showCheckResults();
			return false;
		}
	}
	 function showCheckResults(){
	 document.getElementById('checkresults').style.display="block";
	 }
		window.onload = function(){statusInfo();resizeTabBody( 'tabLines' );};
		window.onresize = function(){resizeTabBody( 'tabLines' )};
	</script>
	</body>
</html>
<%@ include file="/drugUI/common/footer.jsp"%>